package com.itheima.aop;


import com.itheima.anno.LogOperation;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Component
@Aspect
@Slf4j
public class RecordTimeAspect0 {

    @Around("@annotation(logOperation)")
    public Object recordTime(ProceedingJoinPoint pjp , LogOperation logOperation) throws Throwable{
        long start = System.currentTimeMillis();
        Object result = pjp.proceed();

        long end = System.currentTimeMillis();
        String methodName = pjp.getSignature().getName();

        log.info("{}方法执行耗时++++++++++++++++++++++++：{}毫秒",methodName, end-start);
        return  result;
    }

}
